Documentation > CMS Template API Library > Asset > Item[String]

Item[String]

Gets or sets the with the specified key. Setting a value is not permanent unless SaveContent is called with no arguments. Data is set in memory. Assigning a value using [] on the implicit "asset" which is always available can be used to pass data from new.aspx to input.aspx and from post_input.aspx to post_save.aspx. If assigning a value of null, it will be stored as an empty string

Type

System.String

Value

The field value.

Parameters

NameDescriptionType
key The field name. System.String

Code Example

C#

Sample:
// setting example
//new.aspx
asset["foo"] = "bar";

//input.aspx
Input.ShowTextBox("Foo","foo"); //initializes with value "bar"

//reading example

asset.SaveContentField("key","value");
string value = asset["key"];  //returns value since it was already saved to the DB

asset["foo"] = "bar";
string val = asset["foo"];//returns "bar".  This value is in-memory only.

Connect with Crownpeak